package com.kkui.liuxin.shiro_jwt;

import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.Random;

/**
 * description:用来加盐的工具类，生成指定位数的盐
 *这里是5位
 */

@Component
public class saltUtil {

    private final  String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

    @Bean
    public  String salt() {
        String uuid = new String();
        for (int i = 0; i < 4; i++) {
            //charAt() 方法用于返回指定索引处的字符
            char ch = str.charAt(new Random().nextInt(str.length()));
            uuid += ch;
        }
        return uuid;

    }
}